Tata Infotech Previous Years Solved Sample Placement Papers
-
What is an interface in Java?
A: A class
B: A data type
C: A blueprint for a class
D: A data structure
Ans: C -
Which keyword is used to implement an interface?
A: extends
B: new
C: interface
D: implements
Ans: D -
Can an interface extend another interface in Java?
A: No
B: Yes
Ans: B -
Can an interface have a constructor?
A: Yes
B: No
Ans: B -
Which of the following access modifiers are implicitly applied to variables in an interface?
A: private
B: protected
C: public
D: default
Ans: C -
Is it possible to create an instance of an interface?
A: Yes
B: No
Ans: B -
How many interfaces can a Java class implement?
A: None
B: Only one
C: Two
D: As many as needed
Ans: D -
Can an interface inherit from a class?
A: Yes
B: No
Ans: B -
Can an interface method be declared as final?
A: Yes
B: No
Ans: B -
In Java 9, which type of methods can be added to interfaces to share code between methods?
A: Static
B: Private
C: Final
D: Protected
Ans: B -
An interface with no methods is known as?
A: Abstract Interface
B: Marker Interface
C: Empty Interface
D: Functional Interface
Ans: B -
Which keyword is used to define a default method in an interface?
A: static
B: default
C: final
D: abstract
Ans: B -
Are all methods in an interface abstract?
A: Yes
B: No
Ans: B -
Which of these can be contained in an interface?
A: Abstract methods
B: Constants
C: Default and static methods
D: All of the above
Ans: D -
Which Java feature helps achieve multiple inheritance?
A: Abstract classes
B: Static methods
C: Interfaces
D: Enums
Ans: C -
What is the default access modifier of a method in an interface in Java?
A: private
B: protected
C: public
D: None of the above
Ans: C -
Why were default methods introduced in Java 8 interfaces?
A: To provide multiple inheritance
B: To add utility functions
C: To provide backward compatibility with older interface versions
D: For better performance
Ans: C -
How do you access the fourth element of an array named numbers?
A: numbers[4];
B: numbers(3);
C: numbers[3];
D: numbers.get(3);
Ans: C -
Which of the following operators is used for concatenation of two strings?
A: +
B: *
C: &
D: +=
Ans: A -
Which of the following creates a mutable string?
A: String
B: StringBuilder
C: StringChar
D: StringMutable
Ans: B -
In Java, strings are:
A: Primitive data types
B: Immutable objects
C: Mutable objects
D: Arrays of characters
Ans: B -
How do you find the length of a string named 'example'?
A: example.size()
B: example.length()
C: example.getLength()
D: example.len()
Ans: B -
What is the result of the expression "Java" + "Programming"?
A: JavaProgramming
B: Java Programming
C: Java-Programming
D: JavaProgramming-
Ans: A -
Which method is used to compare two strings for equality?
A: ==
B: equals()
C: compare()
D: isEqual()
Ans: B -
Which class can create a string that is thread-safe?
A: String
B: StringBuffer
C: StringBuilder
D: StringSafe
Ans: B -
What is the root class for all Java classes?
A: Object
B: Class
C: Superclass
D: Root
Ans: A -
What is polymorphism?
A: Multiple forms
B: Single form
C: No form
D: Static form
Ans: A